package com.BraveY.Demo10;

import java.util.HashSet;

public class Demo04 {
    public static void main(String[] args) {
        //创建HashSet集合对象
        HashSet<StudentH> hs = new HashSet<StudentH>();
        //创建学生对象
        StudentH s1 = new StudentH("林青霞", 30);
        StudentH s2 = new StudentH("张曼玉", 35);
        StudentH s3 = new StudentH("王祖贤", 33);
        StudentH s4 = new StudentH("王祖贤", 33);
        //把学生添加到集合
        hs.add(s1);
        hs.add(s2);
        hs.add(s3);
        hs.add(s4);
        //遍历集合(增强for)
        for (StudentH s : hs) {
            System.out.println(s.getName() + "," + s.getAge());
        }
    }
}
